from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import time

# 设置 ChromeDriver 的路径
# 创建 Chrome 浏览器选项
options = Options()
options.add_argument('--headless') # 如果你想让浏览器在无头模式下运行，取消注释此行

# 初始化 WebDriver 实例
driver = webdriver.Chrome()

# 访问一个网站
driver.get("http://10.111.14.66")

# 打印页面标题
print(driver.title)

username = driver.find_element(By.ID, "username")
password = driver.find_element(By.ID, "password")
login_button = driver.find_element(By.CLASS_NAME, "loginButton")

username.send_keys("admin")
password.send_keys("Liling@123")
login_button.click()

# 获取cookies
cookies = driver.get_cookies()

# 打印cookies
for cookie in cookies:
    print(cookie)


# 等待页面加载完成
time.sleep(5)

# 关闭浏览器
#driver.quit()